from rest_framework import serializers
from good_article.models import GoodArticle, GoodCategory
from users.models import UserProfile


class UserSerializer(serializers.ModelSerializer):
    class Meta:
        model = UserProfile
        fields = ('id', 'name')

class GoodCategorySerializer(serializers.ModelSerializer):
    class Meta:
        model = GoodCategory
        fields = ('id','name')

class GoodArticleSerializer(serializers.ModelSerializer):
    category = GoodCategorySerializer()
    author = UserSerializer()
    class Meta:
        model = GoodArticle
        fields = ('id', 'category', 'author', 'add_time')